<?php
// +---------------------------------------------------------------------------+
// | This file is part of the KnowledgebasePublisher package                   |
// | KnowledgebasePublisher - web based knowledgebase publisher tool           |
// |                                                                           |
// | Author:  Evgeny Leontev <eleontev@gmail.com>                              |
// | Copyright (c) 2005 Evgeny Leontev                                         |
// |                                                                           |
// | For the full copyright and license information, please view the LICENSE   |
// | file that was distributed with this source code.                          |
// +---------------------------------------------------------------------------+

$controller->loadClass('User', 'user');
$controller->loadClass('UserModel', 'user');
$controller->loadClass('UserView_form', 'user');

$controller->working_dir = $controller->module_dir . 'user/';
$controller->action = 'update';


// initialize objects
$rq =& new RequestData($_GET);
$rp =& new RequestData($_POST);

$obj = new User;
$obj->is_admin = false;
$obj->hidden = array('id', 'active');

$auth = &new AuthPriv();
$manager =& $obj->setManager(new UserModel());
//$manager->checkPriv($priv, $controller->action, @$rq->id);

$rq->id = $auth->getUserId();

if(isset($rp->submit)) {
		
	if(APP_DEMO_MODE) { $controller->go('not_allowed_demo', true); }
	
	$is_error =& $obj->validate($rp->vars, $manager);
	
	if($is_error) {
		$rp->stripVars(true);
		$obj->set($rp->vars);
		//$obj->setPriv(@$rp->vars['priv']);
	
	} else {
		$rp->stripVars();
		
		$obj->setPassword($rp->not_change_pass); // mean not insert in db if not_change_pass = 1
		$obj->set($rp->vars);
		//$obj->setPriv(@$rp->vars['priv']);
		
		$manager->save($obj, $auth->getUserId());
		$controller->go();
	}
}
	
$data = &$manager->getById($rq->id);
$rp->stripVarsValues($data);
$obj->set($data);

//$view = &$controller->getView($obj, $manager, 'UserView_form');
$view = &new UserView_form();
$view->account_view = true;
$view = $view->execute($obj, $manager);
?>